package com.ruoyi.applet.controller;

import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.applet.domain.Category;
import com.ruoyi.applet.service.ICategoryService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 分类Controller
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/applet")
public class CategoryController extends BaseController
{
    @Resource
    private ICategoryService categoryService;

    @RequestMapping("/category")
    public Object selectCategory(@RequestParam("categoryId") Long categoryId){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("parent",categoryService.selectAllByCategoryParentLevelList());
        resultMap.put("child",categoryService.selectAllByCategoryIdCategoryList(categoryId));
        return resultMap;
    }

    @RequestMapping("/search")
    public Object selectCategoryByName(@RequestParam("categoryName") String categoryName){
        return categoryService.selectAllByCategoryNameList(categoryName);
    }
}
